from socket import *
from threading import Thread
#tcp服务端开发, 支持多个客户端连接
def handle_client_request(client_socket1,client_addr1):
    print(f"接收到: {client_addr1}, 发送来的数据: {client_socket1.recv(1024).decode('utf-8')}")
tcp_socket = socket(AF_INET,SOCK_STREAM)
tcp_socket.setsockopt(SOL_SOCKET,SO_REUSEADDR,True)
tcp_addr_port = ('',8080)
tcp_socket.bind(tcp_addr_port)
tcp_socket.listen(128)
while True:
    client_socket,client_addr = tcp_socket.accept()
    t1 = Thread(target=handle_client_request,args=(client_socket,client_addr))
    # t1.setDaemon(True)
    t1.start()
    # client_socket.close()
    # tcp_socket.close()